<template xmlns="http://www.w3.org/1999/html">
  <smart-form ref="form_create" method="POST" url="/sys/role/info"
              :model="form_data" :on-succeed="callback">
    <smart-form-layout require name="authorityCode" label="授权码">
      <smart-text-view name="authorityCode" placeholder="授权码"></smart-text-view>
    </smart-form-layout>
    <smart-form-layout require name="roleName" label="角色名称">
      <smart-text-view name="roleName" placeholder="角色名称"></smart-text-view>
    </smart-form-layout>
    <smart-form-layout require name="description" label="角色描述">
      <smart-text-view type="textarea" name="description" placeholder="角色描述"></smart-text-view>
    </smart-form-layout>
  </smart-form>
</template>

<script>

export default {
    props: {
        // 成功回调，通常是刷新数据表格
        onSucceed: {type: Function}
    },
    data() {
        return {
            // 是否展开弹出层
            expend: false,
            // 当前操作的数据
            row_data: undefined,

            // form-data start 表单数据对象模型
            form_data: [
                {
                    name: 'id', label: 'ID', value: ''
                    , rules: [
                        {required: true, message: '[ID]字段不允许为空 ', trigger: 'blur'},
                        {min: 0, max: 32, message: '最多32字符', trigger: 'blur'}
                    ]
                },
                {
                    name: 'orgId', label: '机构ID', value: ''
                    , rules: [
                        {required: true, message: '[机构ID]字段不允许为空 ', trigger: 'blur'},
                        {min: 0, max: 32, message: '最多32字符', trigger: 'blur'}
                    ]
                },
                {
                    name: 'authorityCode', label: '授权码', value: ''
                    , rules: [
                        {required: true, message: '[授权码]字段不允许为空 ', trigger: 'blur'},
                        {min: 0, max: 32, message: '最多32字符', trigger: 'blur'}
                    ]
                },
                {
                    name: 'roleName', label: '角色名称', value: ''
                    , rules: [
                        {required: true, message: '[角色名称]字段不允许为空 ', trigger: 'blur'},
                        {min: 0, max: 64, message: '最多64字符', trigger: 'blur'}
                    ]
                },
                {
                    name: 'icon', label: '', value: ''
                    , rules: [
                        {required: true, message: '[]字段不允许为空 ', trigger: 'blur'},
                        {min: 0, max: 255, message: '最多255字符', trigger: 'blur'}
                    ]
                },
                {
                    name: 'disabled', label: '是否可用', value: ''
                },
                {
                    name: 'editable', label: '是否可编辑', value: ''
                },
                {
                    name: 'description', label: '描述', value: ''
                    , rules: [
                        {required: true, message: '[描述]字段不允许为空 ', trigger: 'blur'},
                        {min: 0, max: 128, message: '最多128字符', trigger: 'blur'}
                    ]
                },
                {
                    name: 'gmtCreate', label: '创建日期', value: ''
                },
                {
                    name: 'gmtModified', label: '', value: ''
                },
            ]
            // form-data end
        }
    },
    methods: {
        /**
         * 新增/编辑操作成功，关闭当前窗口
         *
         * @param ret 后台响应数据
         */
        callback: function (ret) {
            this.$layers.succeed('操作成功!');
            // 刷新表单列表
            this.onSucceed(ret);
        }
    }
}
</script>
